using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class BattleMountUnitDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            BattleMountUnit data = target as BattleMountUnit;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.type = (BattleMountUnitType) value;
                    break;
                case 2:
                    data.id = (string)value;
                    break;
                case 3:
                    data.initHp = ValueObject.Value<int>(value);
                    break;
                case 4:
                    data.currentHp = ValueObject.Value<int>(value);
                    break;
                case 5:
                    data.updateTime = ValueObject.Value<long>(value);
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            BattleMountUnit data = target as BattleMountUnit;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return data.type;
                case 2:
                    return data.id;
                case 3:
                    return ValueObject.Get(data.initHp);
                case 4:
                    return ValueObject.Get(data.currentHp);
                case 5:
                    return ValueObject.Get(data.updateTime);
            }

            return null;
        }
    }
}